// ==UserScript==
// @name         [kesai]imdb电影辅助
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       kesai
// @match        https://www.imdb.com/title/*
// @grant        none
// @require      https://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    function _kickass(){
       window.open('https://kickass.unblocked.gdn/search.php?q='+movieName);
    }

    function _1337x(){
       //window.open('https://1337x.one/search/'+movieName+'/1/');
       window.open('https://1337x.to/search/'+movieName+'/1/');
    }

    function _subTitle(){
       window.open('https://www.zimuku.cn/search?q='+movieName);
    }
    var text=$("h1").text();
    var movieName=text.substring(0,text.lastIndexOf("(")).trim();
    /*
    var kickassDiv=$("<span style='position:absolute;left:300px;display:inline-block;margin-top: -5px;line-height:36px;height:36px;width:80px;background:#ac9856;text-align:center;vertical-align: middle;cursor:pointer;color:white'>Kickass<span>");
    var $1337xDiv=$("<span style='position:absolute;left:390px;display:inline-block;margin-top: -5px;line-height:36px;height:36px;width:80px;background:#e52d19;text-align:center;vertical-align: middle;cursor:pointer;color:white'>1337x<span>");
    var zimukuDiv=$("<span style='position:absolute;left:480px;display:inline-block;margin-top: -5px;line-height:36px;height:36px;width:80px;background:green;text-align:center;vertical-align: middle;cursor:pointer;color:white'>字幕库<span>");*/

    var kickassDiv=$("<span style='position:relative;float:right;display:inline-block;margin-top: -5px;margin-right: 10px;line-height:36px;height:36px;width:80px;background:#ac9856;text-align:center;cursor:pointer;color:white'>Kickass<span>");
    var $1337xDiv=$("<span style='position:relative;float:right;display:inline-block;margin-top: -5px;margin-right: 10px;line-height:36px;height:36px;width:80px;background:#e52d19;text-align:center;cursor:pointer;color:white'>1337x<span>");
    var zimukuDiv=$("<span style='position:relative;float:right;display:inline-block;margin-top: -5px;margin-right: 10px;line-height:36px;height:36px;width:80px;background:green;text-align:center;cursor:pointer;color:white'>字幕库<span>");

    $(".wlb-title-main-details ").append(kickassDiv);
    $(".wlb-title-main-details ").append($1337xDiv);
    $(".wlb-title-main-details ").append(zimukuDiv);
    kickassDiv.click(function(){
      _kickass();
    });
    $1337xDiv.click(function(){
      _1337x();
    });
    zimukuDiv.click(function(){
      _subTitle();
    });
})();